﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace LittleSolution
{
    public partial class Form1 : Form
    {
        private AppDoc theAppDoc;
        public Form1()
        {
            InitializeComponent();
            theAppDoc = new AppDoc();
            //gListBox1.Hide();
        }

        private void richTextBox1_KeyDown(object sender, KeyEventArgs e)
        {
            //             int i = this.richTextBox1.SelectionStart;
            //             string currentChar = "";
            // 
            //             if (i > 0)
            //             {
            //                 currentChar = this.richTextBox1.Text.Substring(i - 1, 1);
            //             }
            //             if (e.KeyData == Keys.OemPeriod)
            //             {
            //                 // The amazing dot key
            // 
            //                 if (!this.gListBox1.Visible)
            //                 {
            //                     // Display the member listview if there are
            //                     // items in it
            //                     if (populateListBox())
            //                     {
            //                         //this.listBoxAutoComplete.SelectedIndex = 0;
            // 
            //                         // Find the position of the caret
            //                         Point point = this.richTextBox1.GetPositionFromCharIndex(richTextBox1.SelectionStart);
            //                         point.Y += (int)Math.Ceiling(this.richTextBox1.Font.GetHeight()) + 2;
            //                         point.X += 2; // for Courier, may need a better method
            //                         
            //                         this.gListBox1.Location = point;
            //                         this.gListBox1.BringToFront();
            //                         this.gListBox1.Show();
            //                     }
            //                 }
            //                 else
            //                 {
            //                     this.gListBox1.Hide();                    
            //                 }

        }

        private void tsbtnDefineObjTemp_Click(object sender, EventArgs e)
        {
            DisplayView(eViews.DEFINE_OBJECT_TEMP);
        }

        private void tsbtnAddObj_Click(object sender, EventArgs e)
        {
            DisplayView(eViews.ADD_NEW_OBJ);
        }

        private void tsbtnDefineTemp_Click(object sender, EventArgs e)
        {
            DisplayView(eViews.DEFINE_LITTLE_TEMP);
        }

        private void tsbtnSelectLittle_Click(object sender, EventArgs e)
        {
            DisplayView(eViews.SELECT_LITTLE);
        }
        private void DisplayView(eViews viewType)
        {
            panel1.Controls.Clear();
            Control control=ViewsFactory.GetView(viewType);
            if (control!=null)
            {
                panel1.Controls.Add(control);
                control.Dock = DockStyle.Fill;
            }                                             
        }
    }

    //         private bool populateListBox()
    //         {
    //             return true;
    //         }
}

